const DB = require('../../../utils/db')
// 引入jwt token工具
const JwtUtil = require('../../../utils/jwt')
/**
 * GET
 * 根据群聊id，获取群聊详细信息
 */

module.exports = async (ctx) => {
  // 获取token
  let token = ctx.request.header.authorization
  let jwt = new JwtUtil(token)
  // 用token获取到userid
  let userid = jwt.verifyToken()
  let groupid = ctx.request.query.groupid
  const groupMember = await DB.query(
    `select u.userid, u.username,u.avatar from user_group ug join user u on ug.userid=u.userid where groupid='${groupid}'`
  )
  ctx.body = {
    code: 0,
    data: groupMember,
  }
}
